package com.bgs.ThreeConfig;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @author Asia
 * @version 1.0
 * @description: TODO
 * @date 2021/9/28 15:45
 */
@Component
@Configuration
public class DirectExchangeTestThree {

    public static final String REPERTORY_DIRECT_EXCHANGE_NAME = "repertory.exchange.name";
    public static final String REPERTORY_DIRECT_EXCHANGE_ROUTING_KEY_NAME = "repertory.exchange.routing.key";
    public static final String REPERTORY_DIRECT_EXCHANGE_QUEUE_NAME = "repertory.exchange.queue";
    public static final String MSG_DL_DIRECT_EXCHANGE_NAME = "msg.dl.exchange.name";
    public static final String MSG_DL_DIRECT_EXCHANGE_ROUTING_KEY_NAME = "msg.dl.exchange.routing.key";
    public static final String MSG_DL_DIRECT_EXCHANGE_QUEUE_NAME = "msg.dl.exchange.queue";

    @Bean
    public DirectExchange RepertoryDirectExchange() {
        return new DirectExchange(REPERTORY_DIRECT_EXCHANGE_NAME);
    }

    @Bean
    public Queue RepertoryQueue() {
        return new Queue(REPERTORY_DIRECT_EXCHANGE_QUEUE_NAME);
    }

    @Bean
    public Binding RepertoryBinding() {
        return BindingBuilder.bind(RepertoryQueue()).to(RepertoryDirectExchange()).with(REPERTORY_DIRECT_EXCHANGE_ROUTING_KEY_NAME);
    }
}
